﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MixerReport.Common
{
    /// <summary>
    /// 原料帮助器
    /// </summary>
    public class MaterialHelper
    {
        MaterialConfig[]? _materials;
        /// <summary>
        /// 创建一个新的 <see cref="MaterialHelper"/>
        /// </summary>
        public MaterialHelper()
        {
            var configuration = new ConfigurationBuilder()
                    .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                    .AddJsonFile("materialsettings.json").Build();
            _materials = configuration.GetSection("Materials").Get<MaterialConfig[]>();
        }
        /// <summary>
        /// 获取物料配置集
        /// </summary>
        public MaterialConfig[]? GetMaterials()
        {
            return _materials; 
        }

    }
}
